// fields.cpp
// Customizer_Pro
// Protea Customizer Pro / Business Logic for managing fields
// Copyright (C) 2003, 2004, 2005 eXegeSys, Inc.
// Copyright (C) 2008 Bruce A. James
//
// This program is part of the Protea Project.
//
// The Protea Project is free software; you can redistribute it and/or modify it 
// under the terms of the GNU General Public License as published by the 
// Free Software Foundation, either version 3 of the License, or (at your 
// option) any later version.
//
// The Protea Project is distributed in the hope that it will be useful, but 
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
// for more details.
// 
// You should have received a copy of the GNU General Public License along 
// with this program.  If not, see <http://www.gnu.org/licenses/>.
//
// Please send correspondence to:
//
// theproteaproject@gmail.com
//

#include "pro_customizer.h"

//@ SEC 2
//
//@ CHA AddFieldPro
//@ COD AddFieldPro
//@ NUM 190
//@ CRI FIELD_NAME
//@ TAB FIELD_DESCRIPTOR Write 
//@ TAB FIELD_NBR_POOL Write
//
//@ GEN AddField will create a new field and write a new FIELD_DESCRIPTR record
//
TRANSACTION_CODE( AddFieldPro ) 
{
	//@ GRS Start the transaction
	START_TXN( AddFieldPro );
		//@ GRS Start database transaction
		START_DB_TXN();
			AddFieldInternal( &txnvars, true );
		END_DB_TXN();

		LOG_TRANSACTION();
		//@ GRE End Database transaction
	CLEANUP_TXN();
	END_TXN();
	//@ GRE End the transaction
};







//
//@ CHA DelFieldPro
//@ COD DelFieldPro
//@ NUM 190
//@ CRI FIELD_NAME
//@ TAB FIELD_DESCRIPTOR Write 
//@ TAB FIELD_NBR_POOL Write 
//
//@ GEN DelField will delete FIELD_DESCRIPTR records
//
TRANSACTION_CODE( DeleteFieldPro ) {

	XCBuffer* TransBuf = NULL;

	//@ GRS Start the transaction
	START_TXN( DeleteFieldPro );
		START_DB_TXN();
			DelFieldInternal( &txnvars, true );
		END_DB_TXN();

		LOG_TRANSACTION();
	CLEANUP_TXN();
	END_TXN();
	//@ GRE End the transaction
};





//
//@ CHA ChgFieldPro
//@ COD ChgFieldPro
//@ NUM 190
//@ CRI FIELD_NAME
//@ CRI APPL_NBR
//@ TAB FIELD_DESCRIPTOR Write
//
//@ GEN ChgField will change FIELD_DESCRIPTOR records
//
TRANSACTION_CODE( ChgFieldPro ) {

	//@ GRS Start the transaction
	START_TXN( ChgFieldPro );
		START_DB_TXN();
			ChgFieldInternal( &txnvars, true );
		END_DB_TXN();

		LOG_TRANSACTION();

		//@ Return the output buffer
		App->TransResponse( txnvars.result, txnvars.buffer, TRANS_HEADER_TYPE );

	CLEANUP_TXN();
	END_TXN();
	//@ GRE End the transaction
};




//
//@ CHA CopyFieldPro
//@ COD CopyFieldPro
//@ NUM 190
//@ CRI FIELD_NAME
//@ CRI APPL_NBR
//@ TAB FIELD_DESCRIPTOR Write
//
//@ GEN CopyField will change FIELD_DESCRIPTOR records
//
TRANSACTION_CODE( CopyFieldPro ) {

	//@ GRS Start the transaction
	START_TXN( CopyFieldPro );
		START_DB_TXN();
			CopyFieldInternal( &txnvars, true );
		END_DB_TXN();

		LOG_TRANSACTION();

		//@ Return the output buffer
		App->TransResponse( txnvars.result, txnvars.buffer, TRANS_HEADER_TYPE );

	CLEANUP_TXN();
	END_TXN();
	//@ GRE End the transaction
};
